use std::sync::Arc;

use event_queue::EventQueue;
use grafbase_telemetry::grafbase_client::Client;
use runtime::extension::Token;

use crate::graphql_over_http::{ContentType, ResponseFormat};

/// Context only used early in the request processing before generating the RequestContext used
/// everywhere else. Contrary to the RequestContext this one never fails to be created.
pub(crate) struct EarlyHttpContext {
    pub method: http::method::Method,
    pub can_mutate: bool,
    pub uri: http::Uri,
    pub response_format: ResponseFormat,
    pub content_type: ContentType,
    pub include_grafbase_response_extension: bool,
    pub include_mcp_response_extension: bool,
}

/// Context associated with the HTTP request. For batch requests and a websocket session, a single RequestContext is
/// created and shared.
pub(crate) struct RequestContext {
    pub can_mutate: bool,
    pub headers: http::HeaderMap,
    pub websocket_init_payload: Option<serde_json::Map<String, serde_json::Value>>,
    pub response_format: ResponseFormat,
    pub client: Option<Client>,
    pub token: Token,
    pub subgraph_default_headers: http::HeaderMap,
    pub include_grafbase_response_extension: bool,
    pub include_mcp_response_extension: bool,
    pub event_queue: Arc<EventQueue>,
    pub hooks_context: Arc<[u8]>,
}
